
#ifndef H_C_LIST_H
#define H_C_LIST_H

#include "ctypes.h"
#include "citerator.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct tagSListNode{
	struct tagSListNode* pstPrev;
	struct tagSListNode* pstNext;
	char*                pcValue;
}SListNode, *PSListNode;

typedef struct tagSList{
	EContainerType  eContainerType;
	SStlcType       stStlcType;	
	SListNode       stListNode;
	size_t          szNodeCnt;
	PFCompare       pfnCompare;	
	PFDestroy       pfnDestroy;
}SList, *PSList;

STLCDLL_EXPORTS SList       StlcListCreate( size_t a_szTypeSize, const char* a_pcTypeName );
STLCDLL_EXPORTS void        StlcListInit( PSList a_pstList, PFCompare a_pfnCompare );
STLCDLL_EXPORTS void        StlcListInitN( PSList a_pstList, PFCompare a_pfnCompare, size_t a_szCount );
STLCDLL_EXPORTS void        StlcListInitElem( PSList a_pstList, PFCompare a_pfnCompare, size_t a_szCount, ... );
STLCDLL_EXPORTS void        StlcListInitCopy( PSList a_pstList, const SList* a_pstListSrc );
STLCDLL_EXPORTS void        StlcListInitCopyRange( PSList a_pstList, const SIterator a_stIterBegin, const SIterator a_stIterEnd );

STLCDLL_EXPORTS bool        StlcListSameType( const SList* a_pstListFirst, const SList* a_pstListSecond );
STLCDLL_EXPORTS size_t      StlcListSize( const SList* a_pstList );
STLCDLL_EXPORTS bool        StlcListEmpty( const SList* a_pstList );
STLCDLL_EXPORTS size_t      StlcListMaxSize( const SList* a_pstList );
STLCDLL_EXPORTS bool        StlcListEqual( const SList* a_pstListFirst, const SList* a_pstListSecond );
STLCDLL_EXPORTS bool        StlcListNotEqual( const SList* a_pstListFirst, const SList* a_pstListSecond );
STLCDLL_EXPORTS bool        StlcListLess( const SList* a_pstListFirst, const SList* a_pstListSecond );
STLCDLL_EXPORTS bool        StlcListGreat( const SList* a_pstListFirst, const SList* a_pstListSecond );
STLCDLL_EXPORTS bool        StlcListLessEqual( const SList* a_pstListFirst, const SList* a_pstListSecond );
STLCDLL_EXPORTS bool        StlcListGreatEqual( const SList* a_pstListFirst, const SList* a_pstListSecond );

STLCDLL_EXPORTS void        StlcListAssign( PSList a_pstListDest, const SList* a_pstListSrc );
STLCDLL_EXPORTS void        StlcListAssignRange( PSList a_pstList, const SIterator *a_pstIterBegin, const SIterator *a_pstIterEnd );
STLCDLL_EXPORTS void        StlcListSwap( PSList a_pstListFirst, PSList a_pstListSecond );
STLCDLL_EXPORTS void*       StlcListAt( const SList* a_pstList, size_t a_szPos );
STLCDLL_EXPORTS void*       StlcListFront( const SList* a_pstList );
STLCDLL_EXPORTS void*       StlcListBack( const SList* a_pstList );
STLCDLL_EXPORTS SIterator   StlcListBegin( const SList* a_pstList );
STLCDLL_EXPORTS SIterator   StlcListEnd( const SList* a_pstList );

STLCDLL_EXPORTS void        StlcListInsertRange( PSList a_pstList, PSIterator a_pstIterator, PSIterator a_pstIterBegin, PSIterator a_pstIterEnd );
STLCDLL_EXPORTS void        StlcListPushBack( PSList a_pstList, ... );
STLCDLL_EXPORTS void        StlcListPopBack(  PSList a_pstList );
STLCDLL_EXPORTS size_t      StlcListErase( PSList a_pstList, ... );
STLCDLL_EXPORTS SIterator   StlcListErasePos( PSList a_pstList, SIterator a_stIterator );
STLCDLL_EXPORTS SIterator   StlcListEraseRange( PSList a_pstList, SIterator a_stIterBegin, SIterator a_stIterEnd );
STLCDLL_EXPORTS void        StlcListResize( PSList a_pstList, size_t a_szResize );
STLCDLL_EXPORTS void        StlcListClear( PSList a_pstList );

STLCDLL_EXPORTS void        StlcListSort( PSList a_pstList, PFSort a_pfnSort, PFCompare a_pfnCompare );
STLCDLL_EXPORTS void*       StlcListFind( const SList* a_pstList, ... );
STLCDLL_EXPORTS void*       StlcListFindN( const SList* a_pstList, size_t a_szIndex, ... );
STLCDLL_EXPORTS SIterator   StlcListSearch( const SList* a_pstList, PFSearch a_pfnSearch, PFCompare a_pfnCompare, ... );
STLCDLL_EXPORTS SIterator   StlcListSearchN( const SList* a_pstList, PFSearch a_pfnSearch, PFCompare a_pfnCompare, size_t a_szIndex, ... );
STLCDLL_EXPORTS void		StlcListDestroy( PSList a_pstList );


STLCDLL_EXPORTS SIterator   StlcListIteratorCreate(void);
STLCDLL_EXPORTS bool        StlcListIteratorBelongTo( const SList* a_pstList, const SIterator a_stIterator );
STLCDLL_EXPORTS bool        StlcListIteratorEqual( const SList* a_pstList, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
STLCDLL_EXPORTS void        StlcListIteratorGetValue( const SList* a_pstList,const SIterator a_stIterator, void* a_pValue );
STLCDLL_EXPORTS void        StlcListIteratorSetValue( const SList* a_pstList, const SIterator a_stIterator, void* a_pValue );
STLCDLL_EXPORTS const void* StlcListIteratorGetPointer( const SList* a_pstList, const SIterator a_stIterator ); 
STLCDLL_EXPORTS void        StlcListIteratorNext( const SList* a_pstList, PSIterator a_pstIterator );
STLCDLL_EXPORTS void        StlcListIteratorPrev( const SList* a_pstList, PSIterator a_pstIterator );
STLCDLL_EXPORTS void*       StlcListIteratorAt( const SList* a_pstList, const SIterator a_stIterator, size_t a_szIndex );
STLCDLL_EXPORTS void        StlcListIteratorNextN( const SList* a_pstList, PSIterator a_pstIterator, int a_nStep );
STLCDLL_EXPORTS void        StlcListIteratorPrevN( const SList* a_pstList, PSIterator a_pstIterator, int a_nStep );
STLCDLL_EXPORTS int         StlcListIteratorDistance( const SList* a_pstList, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
STLCDLL_EXPORTS bool        StlcListIteratorLess( const SList* a_pstList, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
STLCDLL_EXPORTS bool        StlcListIteratorBefore( const SIterator a_stIterFirst, const SIterator a_stIterSecond );

#ifdef __cplusplus
}
#endif

#endif